package com.laoxu.microservice.productservice.service;

import com.laoxu.microservice.productservice.pojo.Product;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 商品服务
 * @author: luohanye
 * @create: 2019-10-20
 **/
@Service
public class ProductService {
    private static final Map<Long, Product> MAP = new HashMap<Long, Product>();

    static { // 准备一些静态数据
        MAP.put(1L, new Product(1L, "商品标题1", "http://图片1", "商品描述1", 1000L));
        MAP.put(2L, new Product(2L, "商品标题2", "http://图片2", "商品描述2", 2000L));
        MAP.put(3L, new Product(3L, "商品标题3", "http://图片3", "商品描述3", 3000L));
        MAP.put(4L, new Product(4L, "商品标题4", "http://图片4", "商品描述4", 4000L));
        MAP.put(5L, new Product(5L, "商品标题5", "http://图片5", "商品描述5", 5000L));
        MAP.put(6L, new Product(6L, "商品标题6", "http://图片6", "商品描述6", 6000L));
        MAP.put(7L, new Product(7L, "商品标题7", "http://图片7", "商品描述7", 7000L));
        MAP.put(8L, new Product(8L, "商品标题8", "http://图片8", "商品描述8", 8000L));
    }

    /**
     * 模拟实现商品查询
     *
     * @param id
     * @return
     */
    public Product queryProductById(Long id) {
        return MAP.get(id);
    }
}
